package com.erpanderp.wam.usm.view.user;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;


import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;



@ManagedBean
@ViewScoped
public class UploadMasterDataBean implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String name;
	private InputStream csvFile;
	public UploadMasterDataBean() {
		// TODO Auto-generated constructor stub
		System.out.println("UPLOAD MASTER DATA BEAN INTIALIZING");
	}
	
	public void uploadHandler(FileUploadEvent e) throws IOException{
		ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
		String fileName = e.getFile().getFileName();
		csvFile = e.getFile().getInputstream();
		UploadedFile file = e.getFile();
		System.out.println("FILE NAME "+file.getSize());
		
		
	}

	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public InputStream getCsvFile() {
		return csvFile;
	}

	public void setCsvFile(InputStream csvFile) {
		this.csvFile = csvFile;
	}

	

}
